package wifiunion.com.notice.widget.treedialog;


import java.util.HashMap;

import wifiunion.com.notice.DataSyncContact;

/**
 * Created by Administrator on 2017/5/25.
 */

public class TreefilterPresenter implements DataSyncContact.Presenter, DataSyncContact.Callback {


    private int mType = 0;

    TreefilterModel treefilterModel;

    private TreefilterContact.View mView;

    public TreefilterPresenter(TreefilterContact.View view, int type) {
        mType = type;
        mView = view;
        treefilterModel = new TreefilterModel();
    }


    @Override
    public void onSuccess(Object data) {
        switch (mType) {
            case 0:
                mView.onSuccess(data);
                break;
            case 1:
                mView.getCurrentTreeSuccess(data);
                break;
        }

    }

    @Override
    public void onServerFailed(Object errorObj) {

        switch (mType) {
            case 0:
                mView.onError(errorObj);
                break;
            case 1:
                mView.getCurrentTreeFailed(errorObj);
                break;
        }

    }

    @Override
    public void onNetFailed() {

        switch (mType) {
            case 0:
                mView.onError("网络异常");
                break;
            case 1:
                mView.getCurrentTreeFailed("网络异常");
                break;
        }

    }

    @Override
    public void start() {

    }

    @Override
    public void start(HashMap<String, Object> param1s) {

    }

    public void getTreeFilter(HashMap<String, Object> param1s) {
        treefilterModel.getTreeFilterRequest(param1s, this);
    }


    public void getCurrentTree(HashMap<String, Object> param1s) {
        treefilterModel.getCurrentTreeRequest(param1s, this);
    }


}
